<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>分配权限</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="分配,权限">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="${CONTEXT_PATH}/common/tree/treeCss.css">
	<script type="text/javascript" src="${CONTEXT_PATH}/common/tree/jquery.simple.tree.js"></script>
	
	<script type="text/javascript">
	var simpleTreeCollection;
	$(document).ready(function(){
		simpleTreeCollection = $('#simpleTree').simpleTree({
			drag:false,
			docToFolderConvert:true,
			afterClick:function(node){
			}
		});
		
		initPrivilege();
	});
	
	function privilegeCbClick(obj)
	{
		checkParent(obj);
		checkChild(obj);
	}
	
	function checkAll(cb)
	{
		var obj = $(cb);
		var c = $('#li0 input');
		for(var j = 0; j < c.length; j++)
		{
			$(c.get(j)).attr('checked', obj.attr('checked'));
		}
	}
	
	function assignPrivilege()
	{
		$.ajax({
    		url:'${CONTEXT_PATH}/inner/privilege/assignPrivilege.action',
    		type:'post',
    		data:$("#frm").serialize(),
    		success:
    			function(result){
    				showMsg('保存成功。', function(){window.close();});
    			}
    	});
	}
	
	function initPrivilege()
	{
		var ids = [<s:property value='hasPrivilegeIds' />];
		var len = ids.length;
		for(var i = 0; i < len; i++)
		{
			var privilegeCbx = $('#privilegeCb' + ids[i]);
			privilegeCbx.attr('checked', true);
		}
	}
	
	</script>
	
	<style type="text/css">
	form
	{
		height:100%;
	}
	</style>
  </head>
  
  <body style="margin:-22px -22px 0px -22px; overflow:hidden;">
  	<s:form name="frm" id="frm" method="post">
  		<s:hidden name="role.id"></s:hidden>
	  	<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
	 		<jsp:param name="menuLink" value="[{'name':'系统管理'},{'name':'权限管理'},{'name':'角色管理'},{'name':'分配权限'}]"/>
	 		<jsp:param name="width" value="80%"/>
	 	</jsp:include>
	  	<table width="100%" height="85%" cellspacing="0">
	  		<tr>
	  			<td align="left" valign="top" height="95%">
	  				<div style="width:100%; height:100%; overflow-y:auto; display:inline-block;">
	  				
	  					<ul id="simpleTree" class="simpleTree">
							<li class="root" id="li0"><span>主菜单</span>
								<input type="checkbox" onclick="checkAll(this)" id="privilegeCb0" />
								<s:property value="tree" escape="false"/>
							</li>
						</ul>
						
	  				</div>
	  			</td>
	  		</tr>
	  	</table>
	  	
	  	<table width="100%" cellspacing="0">
   			<tr>
   				<td align="center" valign="bottom" height="30">
   					<input type="button" value="保存" class="btn" onclick="assignPrivilege()" />
   				</td>
   			</tr>
   		</table>
    </s:form>
  </body>
</html>
